home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / bitstuf.com / BITSTUFF.DOC < prev    next >
Encoding:
Text File  |  1990-08-15  |  4.1 KB  |  103 lines

  1.      Aug 12, 1989
  2.      BITVAL and BITSTR Updated 7/28/90 for QBX/BC7 far string compatibility
  3.  
  4.      This ARC contains the MASM source and .OBJ for a set of bit-level
  5. manipulation routines to use with QB/BC.  If you make modifications, you'll
  6. need MASM 5.1 to reassemble.
  7.  
  8.      Routines are included to set, clear, toggle and examine the state of any
  9. single bit in a 16-bit word.  These allows the programmer to maintain 16
  10. separate flags in a single integer, with quick access to any flag.  If you
  11. use global flags, you'll find these fast and convenient.
  12.  
  13.      Also included are routines to convert between numeric values and binary
  14. strings, for example "10011".
  15.  
  16.      Uploaded to MSSYS for the free use of its members.  Not copyrighted.
  17. If you find these useful, drop me a note.  Likewise, if you encounter any
  18. problems or have comments or questions, please let me know at once:
  19.  
  20.      Jim Mack [76630,2012] via MSSYS
  21.  
  22.      Detailed descriptions follow.  Also see the MASM source and the QB test
  23. program for more information.
  24.  
  25.  
  26.  
  27. ═══════════════
  28.  
  29.      DECLARE SUB SetBit (bitnumber%, word%)
  30.      DECLARE SUB ClearBit (bitnumber%, word%)
  31.      DECLARE SUB ToggleBit (bitnumber%, word%)
  32.  
  33.      WORD% is the 16-bit quantity where the selected bit resides.
  34.      Set, Clear and ToggleBit alter WORD% directly.
  35.  
  36.      BITNUMBER% ranges from 1 to 16.  If you exceed 16, what happens
  37.      depends on what processor you're using.  Zero affects no bits.
  38.  
  39. ═══════════════
  40.  
  41.      DECLARE FUNCTION BitState% (bitnumber%, word%)
  42.  
  43.      Returns a logical "true" (-1) if the selected bit is set in WORD%, or a
  44.      logical "false" (0) otherwise.  WORD% is not altered.
  45.  
  46. ═══════════════
  47.  
  48.      DECLARE FUNCTION BitStr$ (word%)
  49.  
  50.      Returns a 16-character string of ASCII ones and zeros with a "1" in
  51.      each position where a bit is set in WORD%.  For example, passing 12
  52.      returns the string "0000000000001100".
  53.  
  54. ═══════════════
  55.  
  56.      DECLARE FUNCTION BitVal& (binar$)
  57.  
  58.      Returns a long integer quantity reflecting the value of a passed string
  59.      of ASCII ones and zeroes.  BINAR$ can contain any number of digits, but
  60.      only the first 16 are evaluated.  If it contains fewer than 16 digits,
  61.      they are considered as the less significant bits (i.e. "01" is taken to
  62.      mean "0000000000000001" and evaluates to 1).  Strings which contain
  63.      *any* other character in the first 16 positions are rejected, and a
  64.      value of zero returned.
  65.  
  66. ═══════════════
  67.  
  68.  
  69.          ----------------end-of-author's-documentation---------------
  70.  
  71.                         Software Library Information:
  72.  
  73.                    This disk copy provided as a service of
  74.  
  75.                         The Public (Software) Library
  76.  
  77.          We are not the authors of this program, nor are we associated
  78.          with the author in any way other than as a distributor of the
  79.          program in accordance with the author's terms of distribution.
  80.  
  81.          Please direct shareware payments and specific questions about
  82.          this program to the author of the program, whose name appears
  83.          elsewhere in  this documentation. If you have trouble getting
  84.          in touch with the author,  we will do whatever we can to help
  85.          you with your questions. All programs have been tested and do
  86.          run.  To report problems,  please use the form that is in the
  87.          file PROBLEM.DOC on many of our disks or in other written for-
  88.          mat with screen printouts, if possible.  The P(s)L cannot de-
  89.          bug programs over the telephone.
  90.  
  91.          Disks in the P(s)L are updated monthly, so if you did not get
  92.          this disk  directly from the P(s)L,  you should be aware that
  93.          the files in this set may no  longer be the current versions.
  94.  
  95.          For a copy of the latest monthly software library newsletter
  96.          and a list of the 2,000+ disks in the library, call or write
  97.  
  98.                         The Public (Software) Library
  99.                               P.O.Box 35705
  100.                            Houston, TX 77235-5705
  101.                                (713) 524-6394
  102.  
  103.